/*** Miscelaneous Utility Functions ***/
#ifndef _LIBUTIL_H_
#define _LIBUTIL_H_

#ifdef __cplusplus
extern "C" {
#endif /** cplusplus **/

#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>

#define GETOPT_FINISHED -1
#define REALLOC_INCREMENT 256
#define MAX_WORD_LEN 64
#define WORD 1
#define NON_WORD 0


#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif

/* Create a new block of memory and do vital error checking. 
 * The return value should be free'd by the calling function.
 */
void *safe_malloc (size_t size);

/* Resize a pre-existing block of memory and do vital error checking. 
 * The return value should be free'd by the calling function.
 */
void *safe_realloc (void *old_mem, size_t new_size);

/* Take a current string and create a new copy. The
 * return value should be free'd by the calling function.
 */
char *safe_strdup (const char *str);

/* Parse a file, one character at a time and return the current
 * word or non-word. The variable currw tracks whether the previous
 * return value was a word or non-word */
char *parse_file_char (FILE *data_file, int *currw);

#ifdef __cplusplus
}
#endif /** cplusplus **/

#endif /** _LIBUTIL_H_ **/

